package com.prs.crm.interceptor;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.prs.crm.action.IndexAction;
import com.prs.crm.context.AppContext;

public class PurviewInterceptor extends MethodFilterInterceptor{
	
	
	private static final long serialVersionUID = 1L;

	public String doIntercept(ActionInvocation invocation) throws Exception {
		
		if (!invocation.getAction().getClass().equals(IndexAction.class))
		{
			if (ServletActionContext.getRequest().getRequestURI().indexOf("/remote/")<0)
			{
				if (AppContext.getAccountContext()==null
						|| AppContext.getAccountContext().currentUser()==null)
				{
					return "purview-error";
				}
			}
		}
		return invocation.invoke();
	}
}
